Skip to content

fix accuracy of logcosh(::Union{Float32, Float64}) #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

nsajko
Copy link
Contributor

@nsajko nsajko commented Aug 2, 2025

Fixes #100

@nsajko
Copy link
Contributor Author

nsajko commented Aug 2, 2025

Plots of the error in ULPs after this change

logcosh(::Float32):

f32

logcosh(::Float64):

f64

The plotting happens after downsampling (which just takes the maximum value), which itself happens after smoothing (which also just takes the maximum, i.e., a sliding window maximum). Thus the downsampling and smoothing basically just remove the downward spikes of the noise, preserving the maximum error at the region around each point.

Copy link
Collaborator

@tpapp tpapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

nsajko added 2 commits August 6, 2025 16:04
oscardssmith has been reviewing the `ULPError` code on
JuliaLang/julia#59087

So sync the code with the changes there.
@tpapp tpapp requested a review from devmotion August 8, 2025 06:50
@nsajko
Copy link
Contributor Author

nsajko commented Aug 14, 2025

bump

Copy link
Member

@devmotion devmotion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks good, I just wonder if we could cover Float16 as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

logcosh(x) accuracy vanishes around the zero, at x = 0
3 participants